/**
 * 
 */
package net.sf.cldsql.dj.db;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import net.sf.cldsql.dj.utl.JsonUtl;

/**
 * SjResult
 */
public class QueryResult {
    
    
    private List<Map<String, Object>> rset;
    private int count;
    private int status;
    private List<String> errors;

    public QueryResult(List<Map<String,Object>> rset) {
        this(rset, rset == null ? -1 : rset.size());
    }
    
    public QueryResult(List<Map<String,Object>> rset, int count) {
        this(rset, count, 0, 0, null);
    }
    
    public QueryResult(List<Map<String,Object>> rset,
            int count,
            int offset,
            int status,
            List<String> errors) {
        this.rset = rset;
        this.count = count;
        this.status = status;
        this.errors = errors;
    }

    /**
     * @return rset
     */
    public List<Map<String, Object>> getRset() {
        return rset;
    }

    /**
     * @return count
     */
    public int getCount() {
        return count;
    }

    /**
     * @return errors
     */
    public List<String> getErrors() {
        return errors;
    }

    /**
     * @return status
     */
    public int getStatus() {
        return status;
    }
    
    public String toString() {
        return new JsonUtl().setValue(new HashMap<String, Object>(){
            private static final long serialVersionUID = 1L;
        {
            put("rset", rset);
            put("status", status);
            put("errors", errors);
            put("count", count);
        }}).toString();

    }

}
